﻿@{
    Layout = "_AdminLayout";
    ViewBag.PageName = "template";
}
@model Scottxu.Blog.Models.ViewModels.Admin.TemplateFileManagerViewModel

@section Head {
    <script blog-src="assets/admin/js/templatefilemanager.js"></script>
}

<div class="tpl-portlet-components">
    <div class="portlet-title">
        <div class="caption font-green bold">
            <a href="TemplateManager" class="am-close am-close-alt am-icon-arrow-left"></a> 模板文件列表（@(Model.Template.Name)）
        </div>
    </div>
    <div class="tpl-block">
        <div class="am-g">
            <div class="am-u-sm-12 am-u-md-6">
                <div class="am-btn-toolbar">
                    <div class="am-btn-group am-btn-group-xs">
                        <button type="button" class="am-btn am-btn-default am-btn-success" data-am-modal="{target: '#add_item', closeViaDimmer: 0, width: 600, height: 275}"><span class="am-icon-plus"></span> 新增</button>
                        <button type="button" class="am-btn am-btn-default am-btn-danger" id="delete_select"><span class="am-icon-trash-o"></span> 删除</button>
                    </div>
                </div>
            </div>
            <div class="am-u-sm-12 am-u-md-3">
                <form>
                    <div class="am-input-group am-input-group-sm">
                        <input type="hidden" name="templateGuid" value="@Model.Template.Guid">
                        <input type="text" name="searchMessage" class="am-form-field" placeholder="搜索..." value="@(Model.SearchMessage)">
                        <span class="am-input-group-btn">
                            <button type="submit" class="am-btn am-btn-default am-btn-success tpl-am-btn-success am-icon-search"></button>
                        </span>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="am-g">
        <div class="am-u-sm-12">
            <form blog-admin-action="TemplateManager_Delete" method="post" id="table_form">
                <table class="am-table am-table-striped am-table-hover table-main">
                    <thead>
                    <tr>
                        <th class="table-check"></th>
                        <th class="table-title am-hide-sm-only">名称</th>
                        <th class="table-type am-hide-sm-only">MIME</th>
                        <th class="table-author">虚拟路径</th>
                        <th class="table-set" style="width: 145px">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach (var templateFile in Model.TemplateFiles)
                    {
                        <tr data-guid="@templateFile.Guid">
                            <td>
                                <input type="checkbox" name="deleteGuid" value="@templateFile.Guid">
                            </td>
                            <td class="am-hide-sm-only">
                                <a href="@templateFile.VirtualPath" target="_blank">@(templateFile.Name)</a>
                            </td>
                            <td class="am-hide-sm-only">@(templateFile.MIME)</td>
                            <td class="table-templatefile-virtualpath">@(templateFile.VirtualPath)</td>
                            <td>
                                <div class="am-btn-toolbar">
                                    <div class="am-btn-group am-btn-group-xs">
                                        <button type="button" class="am-btn am-btn-default am-btn-xs am-text-secondary edit-item" data-am-modal="{target: '#edit_item', closeViaDimmer: 0, width: 600, height: 200}"><span class="am-icon-pencil-square-o"></span> 编辑</button>
                                        <button type="button" class="am-btn am-btn-default am-btn-xs am-text-danger delete-item"><span class="am-icon-trash-o"></span> 删除</button>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    }
                    </tbody>
                </table>
            </form>
            <div class="am-cf">
                <div class="am-fr">
                    <pagination pageIndex="@Model.PageInfo.PageIndex" pageCount="@Model.PageInfo.PageCount" parameters="searchMessage=@System.Web.HttpUtility.UrlEncode(Model.SearchMessage)&templateGuid=@Model.Template.Guid"></pagination>
                </div>
            </div>
            <hr>
        </div>
    </div>
</div>
<div class="tpl-alert"></div>
<div class="am-modal am-modal-no-btn" tabindex="-1" id="add_item">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">
            新增
            <a class="am-close am-close-spin" data-am-modal-close>
                <span class="am-icon-times"></span>
            </a>
        </div>
        <div class="am-modal-bd">
            <form class="am-form" style="text-align: left;" id="add_item_form" blog-admin-action="TemplateFileManager_AddItem" method="post">
                <input type="hidden" name="templateGuid" value="@(Model.Template.Guid)">
                <div class="am-form-group">
                    <label for="add_item_virtualpath">虚拟路径</label>
                    <input type="text" class="" id="add_item_virtualpath" name="virtualPath" placeholder="输入虚拟路径" required pattern='(^(\/[^\\\/:*?"<>\|]+)+$)|(^\/$)' maxlength="500">
                </div>
                <div class="am-form-group am-form-file">
                    <label for="add_item_file">文件</label>
                    <div>
                        <button type="button" class="am-btn am-btn-default am-btn-sm">
                            <i class="am-icon-cloud-upload"></i> 选择要上传的文件
                        </button>
                    </div>
                    <input type="file" id="add_item_file" name="file" required>
                </div>
                <hr/>
                <div style="text-align: right;">
                    <button type="submit" class="am-btn am-btn-success"><span class="am-icon-plus"></span> 新增</button>
                    <button type="reset" class="am-btn" data-am-modal-close><span class="am-icon-times"></span> 取消</button>
                </div>
            </form>
        </div>
    </div>
</div>
<div class="am-modal am-modal-no-btn" tabindex="-1" id="edit_item">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">
            编辑
            <a class="am-close am-close-spin" data-am-modal-close>
                <span class="am-icon-times"></span>
            </a>
        </div>
        <div class="am-modal-bd">
            <form class="am-form" style="text-align: left;" id="edit_item_form" blog-admin-action="TemplateFileManager_EditItem" method="post">
                <input type="hidden" name="guid" id="edit_item_guid">
                <div class="am-form-group">
                    <label for="edit_item_virtualpath">虚拟路径</label>
                    <input type="text" class="" id="edit_item_virtualpath" name="virtualPath" placeholder="输入虚拟路径" required pattern='(^(\/[^\\\/:*?"<>\|]+)+$)|(^\/$)' maxlength="500">
                </div>
                <hr/>
                <div style="text-align: right;">
                    <button type="submit" class="am-btn am-btn-success"><span class="am-icon-pencil-square-o"></span> 修改</button>
                    <button type="reset" class="am-btn" data-am-modal-close><span class="am-icon-times"></span> 取消</button>
                </div>
            </form>
        </div>
    </div>
</div>